package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查询菜品数量
     * @param dishId
     * @return
     */
    @Select("select count(1) from setmeal_dish where dish_id = #{dishId}")
    Integer countByDishId(Integer dishId);

    /**
     * 根据菜品id查询套餐菜品关系
     * @param dishId
     * @return
     */
    @Select("select * from setmeal_dish where dish_id = #{dishId}")
    List<SetmealDish> getByDishId(Long dishId);

    /**
     * 插入套餐菜品关系数据
     * @param setmealDish
     */
    // @AutoFill(OperationType.INSERT)  SetmealDish实体中没有对应的属性.
    void insert(SetmealDish setmealDish);

    /**
     * 根据套餐id删除套餐菜品关系
     * @param setmealIds
     */
    void deleteBatchBySetmealId(List<Long> setmealIds);

    /**
     * 根据套餐id查询套餐菜品关系
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getBySetmealId(Long id);
}
